<?php
class Sieu_thi_dia_oc extends Controller{
		var $_data;				
		function Sieu_thi_dia_oc(){
			parent::Controller();
			$this->load->model('sieu_thi_dia_oc_model');				
			$this->load->helper('date');	
		}	
		function index(){
			$this->trang_duyet_tin();
		}
		
		###############################################################
		# TAI KHOAN
		###############################################################
				
		function trang_duyet_tin(){	
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = '0';
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";			
			$this->_data['cpview'] = "trang_ca_nhan";
			$this->_data['cpview_title'] = "Trang tổng hợp cá nhân";			
			$this->load->view('mastertemplate',$this->_data);
		}
			
		###############################################################
		# SIEU THI DIA OC
		###############################################################		
		
		function tin_dang_hien_thi(){
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;	
			$this->_data['url']	   = '/tin_dang_hien_thi';
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "tin_dang_hien_thi";
			$this->_data['cpview_title'] = "Quản lý tin đang hiển thị";
			$this->_data['datagrid'] = $this->sieu_thi_dia_oc_model->tin_dang_hien_thi();
			$this->load->view('mastertemplate',$this->_data);
		}
		function tin_cho_duyet(){
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;	
			$this->_data['url']	   = '/tin_cho_duyet';		
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "tin_dang_hien_thi";
			$this->_data['cpview_title'] = "Quản lý tin chờ duyệt";
			$this->_data['datagrid'] = $this->sieu_thi_dia_oc_model->tin_cho_duyet();
			$this->load->view('mastertemplate',$this->_data);
		}
		function tin_chua_hop_le(){
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;	
			$this->_data['url']	   = '/tin_chua_hop_le';			
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "tin_dang_hien_thi";
			$this->_data['cpview_title'] = "Quản lý tin chưa hợp lệ";
			$this->_data['datagrid'] = $this->sieu_thi_dia_oc_model->tin_chua_hop_le();
			$this->load->view('mastertemplate',$this->_data);
		}
		function tin_khong_su_dung(){
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;	
			$this->_data['url']	   = '/tin_khong_su_dung';		
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "tin_dang_hien_thi";
			$this->_data['cpview_title'] = "Quản lý tin không còn sử dụng";
			$this->_data['datagrid'] = $this->sieu_thi_dia_oc_model->tin_khong_su_dung();
			$this->load->view('mastertemplate',$this->_data);
		}
		function tin_ngung_dang(){
			$this->_data = $this->common_model->general();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;	
			$this->_data['url']	   = '/tin_ngung_dang';		
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "tin_dang_hien_thi";
			$this->_data['cpview_title'] = "Quản lý tin ngừng đăng";
			$this->_data['datagrid'] = $this->sieu_thi_dia_oc_model->tin_ngung_dang();
			$this->load->view('mastertemplate',$this->_data);
		}
		
		###############################################################
		# THONG KE
		###############################################################
		
		function thong_ke(){
			$this->_data = $this->common_model->general();
			$this->_data['bodyview'] = "sieuthidiaoc/template";			
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "thong_ke";
			$this->_data['cpview_title'] = "Thống kê";
			$this->_data['cpview_content'] = $this->sieu_thi_dia_oc_model->thong_ke();
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;
			$this->load->view('mastertemplate',$this->_data);
		}
		
		###############################################################
		# CAP NHAT
		###############################################################
		
		/*function update($id){
			$this->_data = $this->common_model->general();
			$this->_data['bodyview'] = "sieuthidiaoc/template";			
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "update";
			$this->_data['cpview_title'] = "Duyệt tin đăng thành viên";
			$this->_data['bodyview_content'] = $this->sieu_thi_dia_oc_model->thong_tin_tai_san($id);
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;
			$this->load->view('mastertemplate',$this->_data);
		}*/
		function dang_tai_san(){
			//$this->thanh_vien_model->kiem_tra_dang_nhap();
			//$this->load->model('thanh_vien/dia_oc_model');
			if($this->sieu_thi_dia_oc_model->luu_tai_san()){
				$this->_cpanel_redirect($this->sieu_thi_dia_oc_model->status);
			}	
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "update";
			$this->_data['cpview_title'] = "Đăng tài sản";			
			$this->_data['cpview_content'] = $this->sieu_thi_dia_oc_model->thong_tin();
			$this->load->view('mastertemplate',$this->_data);
		}
		//
		function update($id=''){
			//$this->thanh_vien_model->kiem_tra_dang_nhap();
			if(empty($id) || strlen((int)$id)!=strlen($id)){
				redirect('sieu_thi_dia_oc','location');
			}			
			//$this->load->model('thanh_vien/dia_oc_model');
			if($this->sieu_thi_dia_oc_model->luu_tai_san()){
				$this->_cpanel_redirect($this->sieu_thi_dia_oc_model->status);			
			}				
			$this->_data['tab_id'] = $this->sieu_thi_dia_oc_model->_tab_id;				
			$this->_data['bodyview'] = "sieuthidiaoc/template";
			$this->_data['bodyview_title'] = "Trang cá nhân";
			$this->_data['cpview'] = "update";
			$this->_data['cpview_title'] = "Duyệt tin đăng thành viên";			
			$this->_data['cpview_content'] = $this->sieu_thi_dia_oc_model->thong_tin_tai_san($id);
			$this->load->view('mastertemplate',$this->_data);
		}		
		function _cpanel_redirect($status){
			switch($status){
				case '0': redirect('sieu_thi_dia_oc/tin_dang_soan','location');
				case '1': redirect('sieu_thi_dia_oc/tin_cho_duyet','location');
				case '2': redirect('sieu_thi_dia_oc/tin_chua_hop_le','location');
				case '3': redirect('sieu_thi_dia_oc/tin_dang_hien_thi','location');
				case '4': redirect('sieu_thi_dia_oc/tin_ngung_dang','location');
				default:  redirect('sieu_thi_dia_oc','location');
			}
		}
		
		//
		function delete()
		{			
			//$this->load->model('thanh_vien/dia_oc_model');
			if($this->sieu_thi_dia_oc_model->delete()){
				//$this->_cpanel_redirect($this->sieu_thi_dia_oc_model->status);			
				$this->_cpanel_redirect('6');			
			}	
		} 
		
	}
/* End of file */
